package com.lori.netshop.controller;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.lori.netshop.pojo.TbItemParam;
import com.lori.netshop.service.ItemParamService;
import com.lori.netshop.util.NetshopResult;

@Controller
@RequestMapping("/item/param")
public class ItemParamController {
	//注入service
	@Autowired
	private ItemParamService itemParamServiceimp;
	/**
	 * 功能：根据类别id获得tb_item_param表的数据
	 */
	@RequestMapping("/query/itemcatid/{itemCatid}")
	@ResponseBody
	public NetshopResult findOne(@PathVariable long itemCatid){
		return itemParamServiceimp.findByID(itemCatid);
	}
	/**
	 * 功能：保存tb_item_param
	 */
	@RequestMapping("/save/{itemCatid}")
	@ResponseBody
	public NetshopResult save(@PathVariable long itemCatid,String paramData){
		//创建tbitemparam对象
		TbItemParam tbItemParam = new TbItemParam();
		tbItemParam.setItemCatId(itemCatid);
		tbItemParam.setParamData(paramData);
		return itemParamServiceimp.save(tbItemParam);
	}
	/**
	 * 功能：分页显示tb_item_param数据
	 */
	@RequestMapping("/list")
	@ResponseBody
	public Map pagination(int rows,int page){
		Map pagination = itemParamServiceimp.pagination(page, rows);
		return pagination;
	}
}
